package com.kaishengit.dao.core;

import java.util.List;



public class Page<T> {
	private int pageNum=1;
	private int pageSize =20;
	private int offset =0;
	private Long totalPages;
	private Long totalCount;
	private List<T> result;
	private String order;
	private String orderBy;
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		if(pageNum < 1){
			pageNum =1;
		}
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		setOffset((pageNum-1)*this.pageSize);
	}
	public int getOffset() {
		return offset;
	}
	public void setOffset(int offset) {
		this.offset = offset;
	}
	public Long getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(Long totalPages) {
		this.totalPages = totalPages;
		
	}
	public Long getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
		Long result = totalCount/getPageSize();
		if(this.totalCount % pageSize !=0){
			result += 1;
		}
		setTotalPages(result);
	}
	
	
	public List<T> getResult() {
		return result;
	}
	public void setResult(List<T> result) {
		this.result = result;
	}
	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	public String getOrderBy() {
		return orderBy;
	}
	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}
	
}
